<?php

namespace app\home\controller;
use cmf\controller\UserBaseController;
use think\Db;

//打印
class PrintController extends UserBaseController{
    public function prlist(){
        $user = cmf_get_current_user();
        $this->assign($user);
        return $this->fetch();
    }
    public function dayin(){
        $template = "guigu.fr3";
        $ver = 3.0;
        $fields = array(
           array(
             "type" =>"str",
             "size" =>255,
             "name" =>"HAWB#",
             "required"=>false
           ),
            array( "type" => "int",  "size" => 0,  "name" => "NO",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "流水号:",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "订单:",  "required" => false ),
            array( "type" => "str",  "size" => 255,  "name" => "收银员:",  "required" => false ),
            array( "type" => "str",  "size" => 255,  "name" => "时间:",  "required" => false ),
            array( "type" => "str",  "size" => 255,  "name" => "品名:",  "required" => false ),
            array( "type" => "int",  "size" => 0,  "name" => "数量:",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "价格（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "金额（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "现金（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "合计:（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "优惠:（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "应收:（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "实收:（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "找零:（CNY）",  "required" => false ),
            array( "type" => "float",  "size" => 0,  "name" => "抹零:（CNY）",  "required" => false ),
            array( "type" => "AutoInc",  "size" => 0,  "name" => "ID",  "required" => false )
        );
        $rows = array(
          array(
              "HAWB#"=>"860014010055",
              "NO"=>1,
              "流水号:" =>123456,
              "订单:" =>15453,
              "收银员:"=>"陶康",
              "时间:" =>date("Y-m-d H:i:s",time()),
              "品名:"=>"叫了只鸭",
              "数量:"=>2,
              "价格（CNY）"=>888,
              "金额（CNY）"=>23,
              "现金（CNY）"=>45,
              "合计:（CNY）"=>999,
              "优惠:（CNY）"=>25,
              "应收:（CNY）"=>45,
              "实收:（CNY）"=>14,
              "找零:（CNY）"=>56,
              "抹零:（CNY）"=>12,
              "ID"=>1
          )  
        );
        $tableName = "Table1";
        $jsonObject = array(
            "template" =>$template,
            "ver" =>$ver,
            "Tables" =>array(
                array(
                    "Name"=>$tableName,
                    "Cols"=>$fields,
                    "Data"=>$rows
                )
            )
        );
        $jsonStr = json_encode($jsonObject);
        return $this->success($jsonStr);
    }
}

